# Maintainer: David Runge <dvzrv@archlinux.org>

_name=jaraco.stream
pkgname=python-jaraco.stream
pkgver=3.0.3
pkgrel=4
pkgdesc="Routines for handling streaming data"
arch=(any)
url="https://github.com/jaraco/jaraco.stream"
license=(MIT)
depends=(python)
makedepends=(
  python-build
  python-installer
  python-setuptools
  python-setuptools-scm
  python-toml
  python-wheel
)
checkdepends=(
  python-more-itertools
  python-pytest
)
conflicts=(python-jaraco)
replaces=(python-jaraco)
source=(https://files.pythonhosted.org/packages/source/${_name::1}/$_name/$_name-$pkgver.tar.gz)
sha256sums=('3af4b0441090ee65bd6dde930d29f93f50c4a2fe6048e2a9d288285f5e4dc441')
b2sums=('85289efe8e04e93cbceb0053f5025cad3d073deeb113806e25ca06fb88a9b082de6805305de85d1f17b77f61d2d0f4683b2b21f670102b03112b8f7a3fdafd91')

build() {
  cd $_name-$pkgver
  python -m build --wheel --no-isolation
}

check() {
  local _site_packages=$(python -c "import site; print(site.getsitepackages()[0])")

  cd $_name-$pkgver
  # install to temporary location
  python -m installer --destdir=test_dir dist/*.whl
  export PYTHONPATH="test_dir/$_site_packages:$PYTHONPATH"
  pytest -vv test_dir/$_site_packages/jaraco/stream
}

package() {
  cd $_name-$pkgver
  python -m installer --destdir="$pkgdir" dist/*.whl
  install -vDm 644 LICENSE -t "$pkgdir/usr/share/licenses/$pkgname"
  install -vDm 644 *.rst -t "$pkgdir/usr/share/doc/$pkgname"
}
